package com.xilai.cuteBoy.entity;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xilai.cuteBoy.common.util.HttpUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Salary {

    public static void main(String[] args) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("page", "1"));
        params.add(new BasicNameValuePair("rows","500"));
        params.add(new BasicNameValuePair("userCode","XL"));
        String url = "http://manage.xilaikd.com/ixilai-guanli/data/querySalsryPerList";
        String strParam = "XL00013,XL00016,XL00056,XL00086,\n" +
                "XL00092,XL00093,XL00113,XL00116,XL00121,XL00126,XL00138,XL00143,XL00155,XL00162,XL00172," +
                "XL00221,XL00225," +
                "XL00264," +
                "XL00282," +
                "XL00283," +
                "XL00286," +
                "XL00287," +
                "XL00289," +
                "XL00293," +
                "XL00301," +
                "XL00302," +
                "XL00303," +
                "XL00305," +
                "XL00308," +
                "XL00313," +
                "XL00316," +
                "XL00321," +
                "XL00323," +
                "XL00324," +
                "XL00327," +
                "XL00328," +
                "XL00329," +
                "XL00334," +
                "XL00344," +
                "XL00365," +
                "XL00379," +
                "XL00383," +
                "XL00386," +
                "XL00397," +
                "XL00421," +
                "XL00440," +
                "XL00469," +
                "XL00470," +
                "XL00471," +
                "XL00473," +
                "XL00474," +
                "XL00481," +
                "XL00490," +
                "XL00491," +
                "XL00522," +
                "XL00524," +
                "XL00523," +
                "XL00532," +
                "XL00529";
        String[] strings = strParam.split(",");
        List<String> list = new ArrayList<String>();
        for (String string : strings) {
            list.add(string);
        }
        try {
            String str = HttpUtil.doGet(url,params);
            JSONArray jsonArray = JSONObject.parseObject(str).getJSONArray("rows");
            for (int i = 0; i < jsonArray.size(); i++) {
                String userCode = jsonArray.getJSONObject(i).getString("userCode");
                if (list.contains(userCode)) {
                System.out.println("月份==>"+jsonArray.getJSONObject(i).get("remark")+" "+
                        " 【用户名】"+jsonArray.getJSONObject(i).get("userName")+" "+
                        " 【用户编码】"+jsonArray.getJSONObject(i).get("userCode")+" "+
                        " 【基本工资】"+jsonArray.getJSONObject(i).get("basicSalary")+" "+
                        " 【奖金】"+jsonArray.getJSONObject(i).get("bonus")+" "+
                        " 【应发工资】"+jsonArray.getJSONObject(i).get("wages")+" "+
                        " 【实发工资】"+jsonArray.getJSONObject(i).get("trueWages"));
                }
            }
            System.out.println(str);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
